package com.itheima.utils;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/*
* 日期转换工具类
* */
public class DateUtils {


    /*
    * 将日期对象转化为字符串
    * */
    public static String date2String(Date date,String patt){
        SimpleDateFormat sdf = new SimpleDateFormat(patt);
        String format = sdf.format(date);
        return format;
    }

    /*
    * 将字符串转化为日期对象
    * */
    public static Date date2String(String str,String patt) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat(patt);
        Date parse = sdf.parse(str);
        return parse;
    }

}
